<%@  Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DomainModel.Entities.Event>" %>
<h3>
    Host an event</h3>
<%= Html.ValidationSummary("Submit was unsuccessful. Please correct the errors and try again.")%>
<% using (Html.BeginForm("EventEdit", "Event", FormMethod.Post, new { enctype = "multipart/form-data" }))
   { %>
<div class="zone_map float_left">
    <% Html.RenderPartial("EditSingleMap", Model); %>
</div>
<div class="zone_events float_right">
    <%= Html.Hidden("EventID", Model.EventID)%>
    <%= Html.Hidden("UserID", Model.UserID)%>
    <%= Html.Hidden("EditedBy", Model.EditedBy)%>
    <p>
        <label>
            Title:</label>
        <%= Html.TextBox("Title", Model.Title) %>
        <%= Html.ValidationMessage("Title") %>
    </p>
    <p>
        <label>
            Date:</label>
        <%= Html.TextBox("DateEvent", String.Format("{0:yyyy-MM-dd HH:mm}", Model.DateEvent), new { @readonly = "readonly" })%>
        <%= Html.ValidationMessage("DateEvent")%>
        &nbsp;
    </p>
    <p>
        <label>
            Description:</label>
        <br />
        <%= Html.TextArea("Description", Model.Description, new { @class="event_desription_textarea"})%>
        <%= Html.ValidationMessage("Description")%>
    </p>
    <p>
        <!-- Creates a simple input box where you can enter an address
         and a Search button that submits the form. //-->
        <label>
            Address:</label>
        <br />
        <%= Html.TextBox("Address", Model.Address, new {id = "address-textbox" })%>
        <!--
            <input type="submit" name="find" value="Show it" onclick="showLocation(); return false;" />
            -->
        <%= Html.ValidationMessage("Address") %>
    </p>
    <p>
        <label>
            Contact Number:</label>
        <br />
        <%= Html.TextBox("ContactPhone", Model.ContactPhone)%>
        <%= Html.ValidationMessage("ContactPhone") %>
    </p>
     <p>
        <label>
            Tags:</label>
        <br />
    <%= Html.TextBox("TagString", Model.TagString)%>

        <%= Html.ValidationMessage("TagString")%>
        </p>
    <p>
        <%= Html.Hidden("Latitude", Model.Latitude)%>
        <%= Html.Hidden("Longitude", Model.Longitude)%>
    </p>
    <p>
        <input class="button" type="submit" value="Save" />
    </p>
</div>
<% } %>

<script src="../../Scripts/jqueryUI/jquery-timepicker.js" type="text/javascript"></script>

<script type="text/javascript">
    // datetimepicker setting
    $(function() {
        $('#DateEvent').datepicker({
            duration: '',
            showTime: true,
            constrainInput: false,

            // enable image select date 
            showOn: 'button',
            buttonImage: '../../Content/Images/web/event_calendar.png',
            buttonImageOnly: true
        });
    });
</script>

<script type="text/javascript">
    //<![CDATA[
    $(document).ready(function() {
        $("#address-textbox").blur(function(evt) {
            //If it's time to look for an address, 
            // clear out the Lat and Lon
            $("#Latitude").val("0");
            $("#Longitude").val("0");

            var address = jQuery.trim($("#address-textbox").val());
            if (address.length < 1)
                return;
            showLocation();
        });
    });

    //]]>
</script>

